Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Validación de archivo Codeigniter sin parámetro "requerido"

Quiero crear una validación de archivo que no sea obligatoria, pero cuando se inserta, debe ser un archivo zip y un tamaño máximo de 2 MB. Uso Codeigniter 4 & Js, con el siguiente código, cuando la entrada [archivo] está vacía, todavía recibo un error de validación.

 $("#btnReply").click(function(e) { var frmReply = new FormData(); frmReply.append('attachment_reply', $('#attachment_reply')[0].files[0]); e.preventDefault(); $.ajax({ type: 'POST', url: 'http://localhost/syst20/ticketreply/store', enctype: 'multipart/form-data', dataType: 'json', data: frmReply, });

Mi regla de controlador

 if (!$this->validate([ 'attachment_reply' => [ 'label' => 'Attachment', 'rules' => 'ext_in[attachment_reply,zip,rar,7z]|max_size[attachment_reply,2000]', ]])) { $error_description = $this->validator->getErrors(); $callback = array( 'status' => 'failed', 'message' => $error_description, 'ticket_id' => $ticket_id, 'token' => csrf_hash(), ); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!